<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Document</title>
	</head>
	<body>
		<input type="number" id="num1">
		<select name="" id="select">
			<option value="+">+</option>
			<option value="-">-</option>
			<option value="*">*</option>
			<option value="/">/</option>
		</select>
		<input type="number" id="num2">
		<!-- <input type="button" value="=" onclick="var a = 5; var  b = 20; var c = a + b;"> -->
		<input type="button" value="=" id="cal">
		<input type="text" id="result">
	</body>
</html>
<!-- <script src="jquery.js"></script> -->
<script src="calculator.js"></script>
<script>
	var arr = [1, 2, 3];
	console.log(arr[0]);
	console.log(arr);
	arr[0] = 5;
	console.log(arr);


	// 创建一个空数组
	var arr = [];
	// arr[0] = 1;
	// arr[1] = 2;

	for (var i = 0; i < 20; i++) {
		// arr[0] = 0 + 1;
		// arr[1] = 1 + 1;
		// arr[2] = 2 + 1;
		arr[i] = i + 1;
	}
	console.log(arr);

	// 把一个数组中的内容放到另一个数组中
	var arr1 = [2, 3, 4, 5];
	var arr2 = [];
	for (var i = 0; i < arr1.length; i++) {
		arr2[i] = arr1[i];
	}
	console.log(arr2);

	// 把前两数组中元素的和放到第三个数组中
	var arr3 = [4, 5, 7, 9];
	var arr4 = [9, 8, 3, 2];
	var arr5 = [];
	for (var i = 0; i < arr3.length; i++) {
		arr5[i] = arr3[i] + arr4[i];
	}
	console.log(arr5);

	// 数组中的最后一个元素
	console.log(arr5[arr5.length - 1]);

	// 把一个数组中的内容, 倒序放到另一个数组中
	var arr6 = [1, 2, 3, 4, 5];
	var arr7 = [];
	for (var i = 0; i < arr6.length; i++) {
		arr7[i] = arr6[arr6.length - 1 - i];
	}
	console.log(arr7);

	// 随机10个1-100的数放到数组中, 求他们的和, 平均数, 最大数, 最小数
	function randomNum(m, n) {
		return Math.floor(Math.random() * (n - m + 1) + m);
	}
	var array = [];
	var sum = 0;
	var min = 100;
	var max = 1;
	for (var i = 0; i < 10; i++) {
		array[i] = randomNum(1, 100);
		sum += array[i];
		if (min < array[i]) {
			min = min;
		} else {
			min = array[i];
		}

		if (max > array[i]) {
			max = max;
		} else {
			max = array[i];
		}
		// min = min < array[i] ? min : array[i];
		// max = max > array[i] ? max : array[i];
	}
	console.log(array);
	console.log(sum);
	console.log(sum / 10);
	console.log(max);
	console.log(min);








</script>